﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Forget.Data;

namespace Forget.HRBLL.Model
{
    public partial class HolidyInfo
    {
        private static readonly string ADDHOLIDYINFO = "HR_AddHolidyInfo";
        private static readonly string EDITHOLIDYINFO = "";
        private static readonly string DELHOLIDYINFO = "HR_DelHolidyInfo";

        #region properties
        [DataParam(32, SqlDbType.Int)]
        public int? HolidyID { get; set; }

        [DataParam(20, SqlDbType.NVarChar)]
        public string NumberID { get; set; }       

        [DataParam(0, SqlDbType.DateTime)]
        public DateTime Start { get; set; }

        [DataParam(0,SqlDbType.DateTime)]
        public DateTime End { get; set; }       

        [DataParam(32,SqlDbType.Int)]
        public int? Type { get; set; }
        #endregion

        /// <summary>
        /// 添加请假信息
        /// </summary>
        /// <param name="hi"></param>
        /// <returns></returns>
        public static bool AddHolidyInfo(HolidyInfo hi)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hi);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, ADDHOLIDYINFO, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.AddHolInfo", ex.Message, ex.StackTrace);
            }
            return false;
        }

        /// <summary>
        /// 编辑请假信息
        /// </summary>
        /// <param name="hi"></param>
        /// <returns></returns>
        public static bool EditHolidyInfo(HolidyInfo hi)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hi);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, EDITHOLIDYINFO, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.EditHolInfo", ex.Message, ex.StackTrace);
            }
            return false;
        }

        /// <summary>
        /// 删除请假信息
        /// </summary>
        /// <param name="hi"></param>
        /// <returns></returns>
        public static bool DelHolidyInfo(HolidyInfo hi)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hi);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, DELHOLIDYINFO, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.DelHolInfo", ex.Message, ex.StackTrace);
            }
            return false;
        }
    }
}
